package collections;

import java.util.*;

/**
 * Created by pc on 2015/2/15.
 * 目的：去掉数组中的重复元素* 
 * 通过LinkedHashSet可以保证输出时是按插入的顺序
 * 一句话去重数组* *
 */
public class RemoveDuplicateInArray {
    public static void main(String args[]){
        Set<Integer> set = new HashSet<Integer>(Arrays.asList(34,12,34,53,23,0, 0));
        System.out.println(set);
        
        int [] dupArray = new int[] {45, 23, 55, -9, -9, 23};
        Collection<Integer> iSet = new LinkedHashSet<Integer>();
//        Collection<Integer> iSet = new HashSet<Integer>();
        for (int ele: dupArray){
            iSet.add(ele);
        } 
        System.out.println(iSet);

    }  
}
